package me.dwliu.ebase.modules.gen.util;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 查询条件封装器
 *
 * @author liudw
 * @create 2018-03-28 13:38
 **/
public class Query extends LinkedHashMap<String, Object> {

    /**
     * 当前页数
     */
    private int page;
    /**
     * 每页条数
     */
    private int limit;

    public Query(Map<String, Object> param) {
        this.putAll(param);

        this.page = Integer.parseInt(param.get("page").toString());
        this.limit = Integer.parseInt(param.get("limit").toString());

        this.put("offset", (page - 1) * limit);
        this.put("page", page);
        this.put("limit", limit);


    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }
}
